package com.sunnada.edu.system.quartz.timers;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import com.sunnada.edu.system.pub.comet4j.Comet;
import com.sunnada.edu.system.pub.comet4j.CometUtil;

@Component    
public class Comet4jTest {      
      //@Scheduled(cron="0/5 * *  * * ? ")   //每5秒执行一次           
      public void myTest(){      
            Comet comet = new Comet();
            comet.setMsgCount("1");
            List<Map> msgData= new ArrayList<Map>();
            Map mp=new HashMap<String, String>();
            mp.put("msg", "哈哈O(∩_∩)O哈哈~放学别走，校门口见，有人要砍你！");
            msgData.add(mp);
            comet.setMsgData(msgData);
            comet.setUserId("admin");
            new CometUtil().pushTo(comet);//单个发送
            //new CometUtil().pushToAll(comet);//全部发送
      }      
} 
